package com.sundablog.controller.systemsetup.basicsetup.websitesettings;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sundablog.pojo.WebSiteSettings;
import com.sundablog.result.BaseResult;
import com.sundablog.service.systemsetup.basicsetup.websitesettings.WebSiteSettingsService;

/**
 * 网站设置Controller层
 * @ClassName:  WebSiteSettingsController   
 * @Description:TODO(这里用一句话描述这个类的作用)   
 * @author: 哒哒 
 * @date:   2017年12月21日 下午11:35:27   
 *     
 * @Copyright: 2017 www.sundablog.com Inc. All rights reserved.
 */
@Controller
@RequestMapping("/systemsetup/basicsetup/websitesettings")
public class WebSiteSettingsController {
	
	@Autowired
	private WebSiteSettingsService webSiteSettingsService;
	
	/**
	 * 网站设置界面显示
	 * @Title: showIndex   
	 * @Description: TODO(这里用一句话描述这个方法的作用)   
	 * @param: @return      
	 * @return: String      
	 * @throws
	 */
	@RequestMapping("/index")
	public String showIndex() {
		return "/systemsetup/basicsetup/websitesettings/index";
	}
	
	/**
	 * 获取网站设置
	 * @Title: getWebSiteSettings   
	 * @Description: TODO(这里用一句话描述这个方法的作用)   
	 * @param: @return      
	 * @return: BaseResult      
	 * @throws
	 */
	@RequiresPermissions("systemsetup_basicsetup_websitesettings_getWebSiteSettings")
	@RequestMapping("/getWebSiteSettings")
	@ResponseBody
	public BaseResult getWebSiteSettings() {
		WebSiteSettings settings = webSiteSettingsService.getWebSiteSettings();
		return BaseResult.build(200, "", settings);
	}
	
	/**
	 * 修改网站设置
	 * @Title: updateWebSiteSettings   
	 * @Description: TODO(这里用一句话描述这个方法的作用)   
	 * @param: @param webSiteSettings
	 * @param: @return      
	 * @return: BaseResult      
	 * @throws
	 */
	@RequiresPermissions("systemsetup_basicsetup_websitesettings_updateWebSiteSettings")
	@RequestMapping("/updateWebSiteSettings")
	@ResponseBody
	public BaseResult updateWebSiteSettings(WebSiteSettings webSiteSettings) {
		int i = webSiteSettingsService.updateWebSiteSettings(webSiteSettings);
		if (i > 0) {
			return BaseResult.build(200, BaseResult.updataSuccess);
		} else {
			return BaseResult.build(201, BaseResult.updataFail);
		}
	}
	
	
	
}
